﻿package com.wandian.view.mediator.account
{
	import com.wandian.controller.AccountCommand;
	import com.wandian.controller.CLZNoticeName;
	import com.wandian.data.GameData;
	import com.wandian.model.InRoomPlayerDataProxy;
	import com.wandian.model.SwfDataProxy;
	import com.wandian.model.vo.PlayerVo;
	import com.wandian.model.vo.RoomVo;
	import com.wandian.model.vo.WealthVo;
	import com.wandian.util.CLZButton;
	import com.wandian.util.CLZLlistScrollPanel;
	import com.wandian.util.CLZLoadingData;
	import com.wandian.util.CLZTabBar;
	import com.wandian.util.FormatMoney;
	import com.wandian.util.GlowFilterManage;
	import com.wandian.util.GolbalTimer;
	import com.wandian.view.components.ui.AddBtn;
	import com.wandian.view.components.ui.MaskTipPanel;

	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.events.TextEvent;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	import flash.text.TextFormat;

	import org.puremvc.as3.interfaces.*;
	import org.puremvc.as3.patterns.mediator.*;

	/**
	 * 充值记录
	 * @author long
	 * @QQ 108232706
	 * @version 1.0
	 */
	public class RecordMediator extends Mediator
	{
		private var _tabBar:CLZTabBar;
		private var _mcConten:Sprite;
		private var _arrData:Array;
		private var _global:GameData;
		public static const NAME:String="RecordMediator";

		public function RecordMediator(param1:Object=null)
		{
			this._global=GameData.getInstance();
			super(NAME, param1);
			return;
		}

		override public function onRegister():void
		{
			this.init();
			return;
		}

		private function init():void
		{
			this.mcRecord.pay_txt.htmlText="<a href=\"event:pay\">" + GameData.replaceStrTipHtml(GameData.tip["PAY_GLOD"]) + "</a>";
			this.mcRecord.pay_txt.addEventListener(TextEvent.LINK, this.linkTxtHandler);
			this.mcRecord.idName_txt.text=GameData.tip["PAY_RECORD_ID"];
			this.mcRecord.rmb_txt.text=GameData.tip["PAY_RECORD_RMB_NAME"];
			this.mcRecord.gold_txt.text=GameData.tip["PAY_RECORD_GOLD"];
			this.mcRecord.giveGold_txt.text=GameData.tip["PAY_RECORD_GIVE"];
			this.mcRecord.timeName_txt.text=GameData.tip["PAY_RECORD_TIME"];
			this._mcConten=new Sprite();
			this.mcRecord.addChild(this._mcConten);
			this._mcConten.x=13.5;
			this._mcConten.y=67.5;
			this.mcRecord.allRecord_btn.visible=false;
			this.mcRecord.coinRecord_btn.visible=false;
			this.mcRecord.activityRecord_btn.visible=false;
			var _loc_1:Array=[[this.mcRecord.allRecord_btn, GameData.tip["ALL_RECORD"]], [this.mcRecord.coinRecord_btn, GameData.tip["COIN_RECORD"]], [this.mcRecord.activityRecord_btn, GameData.tip["ACTIVITY_RECORD"]]];
			this._tabBar=new CLZTabBar(_loc_1);
			var _loc_2:int=0;
			while (_loc_2 < _loc_1.length)
			{

				_loc_1[_loc_2][0].addEventListener(Event.CHANGE, this.changeTabBarHandler);
				_loc_2=_loc_2 + 1;
			}
			this.sendNotification(CLZNoticeName.WEALTH_RECORD_REQ);
			CLZLoadingData.show(this._mcConten, 730, 384);
			return;
		}

		private function linkTxtHandler(event:TextEvent):void
		{
			this.sendNotification(CLZNoticeName.ON_PAY_VIP);
			return;
		}

		private function changeTabBarHandler(event:Event):void
		{
			var _loc_2:Array=null;
			var _loc_3:WealthVo=null;
			var _loc_4:int=0;
			switch (event.target.name)
			{
				case "allRecord_btn":
				{
					this.showList(this._arrData);
					break;
				}
				case "coinRecord_btn":
				{
					_loc_2=[];
					_loc_4=0;
					while (_loc_4 < this._arrData.length)
					{

						_loc_3=this._arrData[_loc_4] as WealthVo;
						if (_loc_3.type == 1)
						{
							_loc_2.push(_loc_3);
						}
						_loc_4=_loc_4 + 1;
					}
					this.showList(_loc_2);
					break;
				}
				case "activityRecord_btn":
				{
					_loc_2=[];
					_loc_4=0;
					while (_loc_4 < this._arrData.length)
					{

						_loc_3=this._arrData[_loc_4] as WealthVo;
						if (_loc_3.type != 1)
						{
							_loc_2.push(_loc_3);
						}
						_loc_4=_loc_4 + 1;
					}
					this.showList(_loc_2);
					break;
				}
				default:
				{
					break;
				}
			}
			return;
		}

		private function showList(param1:Array):void
		{
			var _loc_5:WealthVo=null;
			var _loc_6:MovieClip=null;
			GameData.removeNumChildre(this._mcConten);
			if (param1 != null)
			{
			}
			if (param1.length == 0)
			{
				return;
			}
			var _loc_2:*=new CLZLlistScrollPanel(1, 726, 27, 2, 2, 384, 730);
			this._mcConten.addChild(_loc_2);
			var _loc_3:*=param1.length;
			var _loc_4:int=0;
			while (_loc_4 < _loc_3)
			{

				_loc_5=param1[_loc_4] as WealthVo;
				_loc_6=GameData.getMovieClip("RecordInfoMc");
				_loc_2.setMc(_loc_6, _loc_4, _loc_3);
				_loc_6.id_txt.text=_loc_5.id;
				if (this._global.userInfo.userVo.gp != GameData.QZONE_SID)
				{
				}
				if (this._global.userInfo.userVo.gp == GameData.FRIEND_SID)
				{
					_loc_6.rmb_txt.text=GameData.replaceStrValue(GameData.tip["VIP_NUM_PRICE_Q"], "NUM", _loc_5.rmb);
				}
				else
				{
					_loc_6.rmb_txt.text=GameData.replaceStrValue(GameData.tip["VIP_NUM_PRICE"], "NUM", _loc_5.rmb);
				}
				_loc_6.gold_txt.text=FormatMoney.setFormatMoney(_loc_5.gold) + " " + GameData.tip["GOLD"];
				_loc_6.giveGold_txt.text=FormatMoney.setFormatMoney(_loc_5.giveGold) + " " + GameData.tip["GOLD"];
				_loc_6.time_txt.text=_loc_5.time;
				_loc_4=_loc_4 + 1;
			}
			return;
		}

		private function updateInfoDataHandler(event:Event):void
		{
			var _loc_2:*=event.target as MovieClip;
			_loc_2.txt.text=_loc_2.info.toString();
			return;
		}

		override public function listNotificationInterests():Array
		{
			return [CLZNoticeName.WEALTH_RECORD_RES];
		}

		override public function handleNotification(param1:INotification):void
		{
			switch (param1.getName())
			{
				case CLZNoticeName.WEALTH_RECORD_RES:
				{
					CLZLoadingData.hide(this._mcConten);
					this._arrData=param1.getBody() as Array;
					this._tabBar.setClickIndex(this.mcRecord.coinRecord_btn);
					break;
				}
				default:
				{
					break;
				}
			}
			return;
		}

		private function get mcRecord():MovieClip
		{
			return viewComponent as MovieClip;
		}

	}
}
